<?
$user="cubecamp_root";
$password="123iTalk";
$database="cubecamp_iTalk";
mysql_connect(localhost,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");

// get data from flex
$name = $_POST['name'];
$peerid= $_POST['peerid'];
$status =  $_POST['status'];

// sql query

$query="select * from user where name='$name' ";
$result=mysql_query($query);
$isNew=($result && mysql_num_rows($result) == 0);

if($isNew){
	$query="insert into user values(null,'$name','$peerid','$status')";
}
else{
	$query="update user set peerid='$peerid' where name='$name'";
}
mysql_query($query);
?>